<?php
	$css_list[0]['url'][] = './tpl/css/album.css';
	$css_list[0]['url'][] = './tpl/css/book.css';
	$js_list[0] = './tpl/js/album.js';
	$js_list[1] = './public/js/jquery.masonry.js';
?>
<!--{template inc/header}-->
<div class="wrapper"> 
	<!--专辑头 -->
	<div class="subnav mt10">
		<a href="{u album}"><img style="margin-right:3px;" src="./tpl/images/album_bg_start.png" />{lang common/album}</a>/ <a href="{$album_cate['url']}">{$album_cate['name']}</a> /<a href="{u u/album uid=$album['uid']}">{$album_user['user_name']}的{lang common/album}</a>
	</div>
	<div class="piece1 mt10">
		<div class="piece1_hd"></div>
		<div class="piece1_bd" id="albumShowBox" shareID="{$album['share_id']}">
			<div class="album_show_title clearfix">
				<div class="user_avatar">
					<!--{getuser $album['uid'] 0 'm,48' ''}-->
					<div class="followdiv">
						<!--{getfollow $album['uid'] inc/getfollow/album}-->
					</div>
				</div>
				<div class="album_intro fleft">
					<h1 class="title">
						{$album['title']}
						<div class="album_mana">
							<!--{if $is_manage_album}-->
							<a href="{u album/edit id=$album['id']}" class="ea_edit">编辑</a>
							<a href="javascript:;" class="del" onclick="$.Remove_Album($album['id'],this,'{u album}')">删除</a>
							<!--{/if}-->
						</div>
					</h1>
					<!--{getuser $album['uid'] 1 '' 'uname gc icard'}-->
					<span style="color: #BBB;padding-left: 5px;">{date $album['create_time']}</span>
					<pre class="album_content">{$album['content']}</pre>
					<div class="element">
						时尚元素：
						<!--{loop $album['tags'] $tag}-->
						<a href="{echo FU('book/shopping',array('tag'=>urlencode($tag)))}">{$tag}</a>
						<!--{/loop}-->
					</div>
				</div>
				<div class="album_imginfo fleft">
					<ul>
						<li style="padding-left:0">
							<a href="{u u/bao uid=$album['uid']}">商品</a><br>
							<span>{$album['goods_count']}</span>
						</li>
						<li>
							<a href="{u u/photo uid=$album['uid']}">图片</a><br>
							<span>{$album['photo_count']}</span>
						</li>
						<li style="background-image:none;">
							<a>被喜欢</a><br>
							<span style="color:#f39;">{$album['collect_count']}</span>
						</li>
					</ul>
					<div class="fo_album clr mt15" id="fo_album">
						<!--{if $album['uid'] == $_FANWE['uid']}-->
						<span class="followed r3">{$album['best_count']}人推荐</span>
						<!--{else}-->
						<!--{if $is_best_album}-->
						<span class="followed r3">已推荐</span>
						<span class="num">{$album['best_count']}人</span>
						<a class="follow_del" href="javascript:void(0);" onclick="$.Remove_Best_Album({$album['id']},this,UpdateAlbumHandler);">取消</a>
						<!--{else}-->
						<a class="follow_add fl" href="javascript:;" onclick="$.Best_Album({$album['id']},UpdateAlbumHandler);">推荐专辑</a>
						<span class="num ml10">{$album['best_count']}人</span>
						<!--{/if}-->
						<!--{/if}-->
					</div>
					<script type="text/javascript">
						function UpdateAlbumHandler(result)
						{
							$("#fo_album").html(result.html);
						}
					</script>
				</div>
			</div>
		</div>
		<div class="piece1_ft"></div>
	</div>
</div>
<div class="wrapper book_box mt20">
	<div class="book_list" id="book_list">
		<!--{loop $share_list $share}-->
		<div class="book_item hide1" shareID="{$share['share_id']}" id="SHARE_LIST_{$share['share_id']}">
			<!--{if $is_manage_album}-->
			<a title="删除" href="javascript:;" class="del_pic" style="display: none;" onclick="$.Tweet_Delete($share['share_id'])"></a>
			<!--{/if}-->
			<div class="bi_body">
				<ul class="pic">
					<!--{loop $share['imgs'] $share_img}-->
					<li>
						<a style="width:200px;" href="{$share_img['url']}" target="_blank">
							<img class="book_img lazyload" original="{getimg $share_img['img'] 200 999}" width="200" src="./tpl/images/lazyload.gif" oldWidth="{$share_img['img_width']}" oldHeight="{$share_img['img_height']}" alt="{$share_img['alt']}"/>
						</a>
						<!--{if $share_img['type'] == 'g'}-->
						<!--{if $share_img['commission'] > 0}-->
						<p class="fl">{lang buy_commission} <script type="text/javascript">$.Commission_Format({$share_img['commission']});</script></p>
						<!--{/if}-->
						<p>{$share_img['price_format']}</p>
						<a class="add_to_album_btn" href="javascript:;" style="display:none;" onclick="$.Show_Rel_Album($share_img['id'],'goods');"></a>
						<!--{else}-->
						<a class="add_to_album_btn" href="javascript:;" style="display:none;" onclick="$.Show_Rel_Album($share_img['id'],'photo');"></a>
						<!--{/if}-->
						
					</li>
					<!--{/loop}-->
				</ul>
				<div class="content">
					{cutstr $share['content'] 96}
				</div>
				<div class="favorite">
					<a href="javascript:;" class="favaImg" onclick="$.Fav_Share({$share['share_id']},this,32,'#SHARE_LIST_{$share['share_id']}');"></a>
					<div class="favDiv"><a target="_blank" class="favCount SHARE_FAV_COUNT" href="{$share['url']}"  >$share['collect_count']</a></div>
					<a target="_blank" href="{$share['url']}" class="creply"><b>{$share['comment_count']}</b>评论</a>
				</div>
				<div class="user">
					<!--{getuser $share['uid'] 0 's,30' ',lazyload'}-->
					<p>
						<span class="u"><!--{getuser $share['uid'] 0 '' ''}--></span>
						<span class="t">{$share['time']}</span>
					</p>
				</div>
			</div>
			<div class="bi_foot"></div>
		</div>
		<!--{/loop}-->
	</div>
	<!--{if $pager['page_count'] > 1}-->
	<div style="padding-top:30px" class="clearfix hide" id="pageBox">
		<div class="pagination"> 
			<!--{subtemplate inc/pages}--> 
		</div>
	</div>
	<!--{/if}-->
	<div class="clear"></div>
</div>
<div class="clear"></div>
<div id="pbLoading" style="background:url(./tpl/images/loading.gif) no-repeat center center;height:52px; display:none;"></div>
<div class="hide">
<!--{if $pager['page_count'] > 0}-->
<!--{loop $pb_list $url}-->
<a href="{$url}">{$url}</a>
<!--{/loop}-->
<!--{/if}-->
</div>
<!--{if !empty($other_album)}-->
<div class="wrapper mt20">
	<div class="image_wall_more clr">
		<div id="album_more" class="piece1 other_t">
    		<div class="piece1_hd"></div>
    		<div class="piece1_bd">
        		<div class="albumall_more">
					<div class="album_more">
						<h1>{$album_user['user_name']}的其他{lang common/album}</h1>
						<a href="{u u/album uid=$album['uid']}" class="more_btn">查看更多</a>
					</div>
            		<ul class="album_more_pic clearfix">
						<!--{eval $album_index = 0;}-->
						<!--{loop $other_album $album}-->
						<!--{eval $album_index++;}-->
						<!--{if $album_index == 3}-->
						<li style="padding-right:0;" class="all_list">
						<!--{else}-->
                        <li class="all_list">
						<!--{/if}-->
							<div class="album_title">
								<a href="{$album['url']}">{cutstr $album['title'] 24}</a>
								<span class="pic_n"><span>{$album['img_count']}&nbsp;图</span><i></i></span>
							</div>
							<ul class="all_pic_s">
								<!--{eval $list_img_counts = array(0,0,0,0,0,0);}-->
								<!--{loop $list_img_counts $imgkey $imgindex}-->
								<!--{eval $img = $album['imgs'][$imgkey];}-->
								<!--{if !empty($img)}-->
								<li><a target="_blank" href="{$album['url']}"><img src="{getimg $img['img'] 100 100}" /></a></li>
								<!--{else}-->
								<li><a target="_blank" class="add_img" href="{$album['url']}"><img src="./tpl/images/none_pic.png" /></a></li>
								<!--{/if}-->
								<!--{/loop}-->
							</ul>
							<p>{cutstr $album['content'] 98}</p>
						</li>
						<!--{/loop}-->
					</ul>
				</div>
			</div>
			<div class="piece1_ft"></div>
		</div>
	</div>
</div>
<!--{/if}-->
<script type="text/javascript">
FANWE.NO_COUNTER = true;
var rowHtml = '<div class="book_item"><div class="bi_body" style="height:#HEIGHT#px;"></div><div class="bi_foot"></div></div>';
var pbUrl = "{$pb_url}";
var imgWidth = 200;
var pbMaxIndex = {$_FANWE['setting']['share_pb_load_count']};

jQuery(function(){
	$(".book_item").live('mouseover',function(){
		$(".del_pic",this).show();
	}).live('mouseout',function(){
		$(".del_pic",this).hide();
	});
	
	<!--{if getIsManage('album')}-->
	$('#albumShowBox,.i_w_f').hover(function(){
		var shareID = this.getAttribute('shareID');
		if(shareID)
			$.GetManageMenu('album',shareID,this);
	},function(){});
	<!--{/if}-->
	
	$(".book_img").each(function(){
		var oldWidth = parseInt(this.getAttribute("oldWidth"));
		var oldHeight = parseInt(this.getAttribute("oldHeight"));
		if(isNaN(oldWidth) || isNaN(oldHeight) || oldWidth == 0 || oldHeight == 0)
		{
			this.height = 0;
		}
		else
		{
			var scale = imgWidth / oldWidth;
			this.height = oldHeight * scale;
		}
	});
	
	$('#book_list').css({"height":"auto","background":"none","overflow":"visible"});
	$('.book_item').css("visibility","visible");
	
	$('#book_list').masonry({
		itemSelector: '.book_item',
		isAnimated:true,
		gutterWidth:18,
		gutterHeight:12,
		columnWidth:226
	});
	<!--{if $pager['page_count'] > 0}-->
	createPBScroll(pbUrl,appendShareItem,pbLoadingFun,2,pbMaxIndex,300);
	<!--{/if}-->
});

function appendBottomItem()
{
	var lefts = new Object();
	var colTotal = 4;
	$(".book_item").each(function(i){
		if($(this).position().top == 0)
		{
			lefts['l'+$(this).position().left] = $(this);
		}
		else
		{
			if(lefts['l'+$(this).position().left].position().top <  $(this).position().top)
				lefts['l'+$(this).position().left] = $(this);
		}
	});
	
	var cols = 0;
	var maxLeft = '';
	var currentSize = 0;
	var maxSize = 0;
	for(var left in lefts)
	{
		cols++;
		currentSize = lefts[left].position().top + lefts[left].height();
		if(currentSize > maxSize)
		{
			maxLeft = left;
			maxSize = currentSize;
		}
	}
	
	var htmlArray = new Array();
	var htmlObjs = new Object();
	html = '';
	for(var left in lefts)
	{
		currentSize = lefts[left].position().top + lefts[left].height();
		if(currentSize < maxSize)
		{
			htmlObjs['h'+(maxSize - currentSize)] = rowHtml.replace("#HEIGHT#",maxSize - currentSize - 20);
			htmlArray.push(maxSize - currentSize);
		}
	}

	var newArray = htmlArray.sort(function(a,b){
		if(a > b)
			return -1;
		else if(a < b)
			return 1;
		else
			return 0;
	});
	
	for(var h=0;h<newArray.length;h++)
	{
		html += htmlObjs['h'+newArray[h]];
	}

	if(colTotal > cols)
	{
		for(var i=0; i< (colTotal - cols);i++)
		{
			html = rowHtml.replace("#HEIGHT#",maxSize - 20) + html;
		}
	}
	html = $('<div>' + html + '</div>').find('.book_item');
	$('#book_list').append(html).masonry('appended',html,true);
}

function appendShareItem(result,index)
{
	html = '<div>' + result + '</div>';
    html = $(html).find('.book_item');
	$(".book_img",html).each(function(){
		var oldWidth = parseInt(this.getAttribute("oldWidth"));
		var oldHeight = parseInt(this.getAttribute("oldHeight"));
		if(isNaN(oldWidth) || isNaN(oldHeight) || oldWidth == 0 || oldHeight == 0)
		{
			this.height = 0;
		}
		else
		{
			var scale = imgWidth / oldWidth;
			this.height = oldHeight * scale;
		}
	});
	$('#book_list').append(html).masonry('appended',html,true,function(){
		if(index >= pbMaxIndex || result == '')
		{
			$("#pageBox").show();
			var fun = function(){
				appendBottomItem();
			}
			setTimeout(fun,1000);
		}
	});
}

function pbLoadingFun(bln)
{
	if(bln)
		$("#pbLoading").show();
	else
		$("#pbLoading").hide();
}
</script>
<!--{template inc/footer}-->
